<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .bg {
      background-color: green;
    }

    .red {
      color: red;
    }
  </style>
</head>

<body>
  <!-- 对象 -->
  <!-- <div id="app">
     写死  :class="{类名:是否加这个类名,类名1:是否加这个类名1}"
     动态  需要把对象声明在data当中，将来操作数据即可操作类名
    <div :class="classObject">盒子</div>
    <button @click="classObject.bg=true">加bg类</button>
    <button @click="classObject.red=true">加red类</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        classObject: {
          bg: false,
          red: false
        }
      }
    })
  </script> -->

  <!-- 数组 -->
  <div id="app">
    <!-- 写死  :class="['类名','类名1']" -->
    <!-- 动态  需要把数组声明在data当中，将来操作数据即可操作类名 -->
    <div class="red" :class="classArray">盒子</div>
    <button @click="classArray.push('bg')">加bg类</button>
    <button @click="classArray.push('red')">加red类</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        classArray: []
      }
    })
  </script>
</body>

</html>